<!DOCTYPE html>
<html lang xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Abalone-博客</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.css">
    <link rel="stylesheet" th:href="@{/css/me_for_mobileBlog.css}">
    <link rel="stylesheet" th:href="@{/css/animate.css}">
    <link rel="stylesheet" th:href="@{/css/typo.css}">
    <link rel="stylesheet" th:href="@{/lib/prism/prism.css}">
    <link rel="stylesheet" th:href="@{/lib/tocbot/tocbot.css}">
    <link rel="stylesheet" th:href="@{/lib/editormd/css/editormd.min.css}">
    <link th:href="@{https://ae01.alicdn.com/kf/U99de1a80dcaa49dca794b6b5ce291106P.jpg}" rel="icon" type="image/x-ico">

</head>
<body>


<br>
<br>

<!--中间内容-->
<div id="waypoint" class="m-container-tiny m-padded-tb-big animated fadeIn m-opacity">
    <div class="ui container">
        <div class="ui top attached segment">
            <div class="ui horizontal link list">
                <div class="item">
                    <div class="content"><a href="#" class="header" th:text="${blog.user.nickname}">....</a></div>
                </div>
                <div class="item">
                    <i class="calendar icon"></i> <span
                        th:text="${#dates.format(blog.updateTime,'yyyy-MM-dd')}">......</span>
                </div>
                <div class="item">
                    <i class="eye icon"></i> <span th:text="${blog.views}">....</span>
                </div>
            </div>
        </div>
        <div class="ui attached segment">
            <!--图片区域-->
            <img src="https://unsplash.it/800/450?image=1005" th:src="@{${blog.firstPicture}}" alt=""
                 class="ui fluid rounded image">
        </div>
        <div class="ui  attached padded segment">
            <!--内容-->
            <div class="ui right aligned basic segment">
                <div class="ui orange basic label" th:text="${blog.flag}">原创</div>
            </div>

            <h2 class="ui center aligned header" th:text="${blog.title}">关于刻意练习的清单</h2>
            <br>
            <!--中间主要内容部分-->
            <div id="content" class="typo  typo-selection js-toc-content m-padded-lr-responsive m-padded-tb-large"
                 th:utext="${blog.content}">
            </div>

            <!--标签-->
            <div class="m-padded-lr-responsive">
                <div class="ui basic violet left pointing label" th:each="tag : ${blog.tags}" th:text="${tag.name}">方法论
                </div>
            </div>

            <!--赞赏-->
            <div th:if="${blog.appreciation}">
                <div class="ui center aligned basic segment">
                    <a th:href="@{/mobile/index}">
                        <button class="ui orange basic circular button">回到首页</button>
                    </a>
                </div>
            </div>
        </div>
        <div class="ui attached positive message">
            <!--博客信息-->
            <div class="ui middle aligned grid">
                <div class="eleven wide column">
                    <ui class="list">
                        <li>作者：<span th:text="${blog.user.nickname}"></span><a href="#" th:href="@{/about}"
                                                                               target="_blank"></a></li>
                        <li>发表时间：<span th:text="${#dates.format(blog.updateTime,'yyyy-MM-dd HH:mm')}"></span></li>
                    </ui>
                </div>
                <div class="five wide column">
                    <img th:href="@{/images/wechat.jpg}" th:src="@{/images/wechat.jpg}" alt=""
                         class="ui right floated rounded bordered image"
                         style="width: 110px">
                </div>
            </div>
        </div>
    </div>


</div>


<br>
<br>

<script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.js"></script>
<script href="https://cdn.jsdelivr.net/npm/jquery.scrollto@2.1.2/jquery.scrollTo.min.js"></script>
<script src="" th:src="@{/js/jquery.min.js}"></script>
<script src="" th:src="@{/js/semantic.min.js}"></script>
<script th:src="@{/js/cursor.js}"></script>
<script th:src="@{/lib/prism/prism.js}"></script>
<script th:src="@{/lib/tocbot/tocbot.min.js}"></script>
<script th:src="@{/lib/qrcode/qrcode.min.js}"></script>
<script th:src="@{/lib/waypoints/jquery.waypoints.min.js}"></script>
<script src="https://cdn.jsdelivr.net/gh/stevenjoezhang/live2d-widget/autoload.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome/css/font-awesome.min.css"/>

<script th:inline="javascript">

    $('.menu.toggle').click(function () {
        $('.m-item').toggleClass('m-mobile-hide');
    });


    tocbot.init({
        // Where to render the table of contents.
        tocSelector: '.js-toc',
        // Where to grab the headings to build the table of contents.
        contentSelector: '.js-toc-content',
        // Which headings to grab inside of the contentSelector element.
        headingSelector: 'h1, h2, h3',
    });

    $('.toc.button').popup({
        popup: $('.toc-container.popup'),
        on: 'click',
        position: 'left center'
    });

    $('.wechat').popup({
        popup: $('.wechat-qr'),
        position: 'left center'
    });


    $('#toTop-button').click(function () {
        document.body.scrollIntoView();
    });


    var waypoint = new Waypoint({
        element: document.getElementById('waypoint'),
        handler: function (direction) {
            if (direction == 'down') {
                $('#toolbar').show(100);
            } else {
                $('#toolbar').hide(500);
            }
            console.log('Scrolled to waypoint!  ' + direction);
        }
    })


    //评论表单验证
    $('.ui.form').form({
        fields: {
            title: {
                identifier: 'content',
                rules: [{
                    type: 'empty',
                    prompt: '请输入评论内容'
                }
                ]
            },
            content: {
                identifier: 'nickname',
                rules: [{
                    type: 'empty',
                    prompt: '请输入你的大名'
                }]
            },
            type: {
                identifier: 'email',
                rules: [{
                    type: 'email',
                    prompt: '请填写正确的邮箱地址'
                }]
            }
        }
    });

    $(function () {
        $("#comment-container").load(/*[[@{/comments/{id}(id=${blog.id})}]]*/"comments/6");
    });


    $('#commentpost-btn').click(function () {
        var boo = $('.ui.form').form('validate form');
        if (boo) {
            console.log('校验成功');
            postData();
        } else {
            console.log('校验失败');
        }

    });

    function postData() {
        $("#comment-container").load(/*[[@{/comments}]]*/"", {
            "parentComment.id": $("[name='parentComment.id']").val(),
            "blog.id": $("[name='blog.id']").val(),
            "nickname": $("[name='nickname']").val(),
            "email": $("[name='email']").val(),
            "content": $("[name='content']").val()
        }, function (responseTxt, statusTxt, xhr) {
//        $(window).scrollTo($('#comment-container'),500);
            clearContent();
        });
    }

    function clearContent() {
        $("[name='content']").val('');
        $("[name='parentComment.id']").val(-1);
        $("[name='content']").attr("placeholder", "请输入评论信息...");
    }


    function reply(obj) {
        var commentId = $(obj).data('commentid');
        var commentNickname = $(obj).data('commentnickname');
        $("[name='content']").attr("placeholder", "@" + commentNickname).focus();
        $("[name='parentComment.id']").val(commentId);
        $(window).scrollTo($('#comment-form'), 500);
    }

    $('.ui.dropdown').dropdown({
        on: 'hover'
    });

</script>
<script th:src="@{/js/cursor.js}"></script>

</body>
</html>